
// Qt
#include <QtCore>
#include <QtGui>

// GMQtExt
#include <messageboxes/messageboxes.h>

// local
#include "myglwidget.h"

// header
#include "mainwindow.h"

#include <gmPBezierCurve.h>
#include <gmPBSplineCurve.h>

#include <gmPBezierSurf.h>

#include <gmPButterfly.h>
#include "gmPCannabis.h"
#include "gmPFolium.h"
#include "gmTorBezier.h"
#include "gmTorBezObj.h"
#include "ERBS.h"
#include <gmPRoseCurve.h>

#include <gmVisualizers>

#include <gmDVector.h>
#include <gmPoint.h>



	using GMlib::Vector;
	using GMlib::Vector3D;
	using GMlib::DVector;
	using GMlib::DMatrix;



MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {

  _widget = new MyGLWidget(this);
  setCentralWidget( _widget );

  _scene = _widget;

  QMenu *file_menu = menuBar()->addMenu( tr("&File") );
  QMenu *file_help = menuBar()->addMenu( tr("&Help") );

  QAction *action_openfile = new QAction( tr("&open"), this );
  file_menu->addAction(action_openfile);

  QAction *action_quit = new QAction( tr("&Quit"), this );
  file_menu->addAction(action_quit);

  QAction *action_about_gmlib = new QAction( tr("About &GMlib"), this );
  file_help->addAction(action_about_gmlib);

  connect( action_openfile, SIGNAL(triggered()), this, SLOT(_slotOpenFile()) );
  connect( action_quit, SIGNAL(triggered()), this, SLOT(_slotQuit()) );
  connect( action_about_gmlib, SIGNAL(triggered()), this, SLOT(_slotAboutGMlib()) );

}

MainWindow::~MainWindow() {}

void MainWindow::_slotOpenFile() {
  QString fileName = QFileDialog::getOpenFileName(this, tr("Open Image"));
	

}

void MainWindow::_slotAboutGMlib() {

  GMQtExt::MessageBoxes::aboutGMlib( centralWidget() );
}

void MainWindow::_slotQuit() {

  // Ask for confirmation on clear
  QMessageBox::StandardButton choice = QMessageBox::question( this, tr("Quit?"), tr("Sure you want to quit?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes );
  switch( choice ) {

    case QMessageBox::No:
      return;
      break;

    case QMessageBox::Yes:
    default:

      // Remove all Selections
      close();
      break;
  }
}

void MainWindow::initScene() {

  _widget->initScene();



	////GMlib::PButterfly<double> *mycurve = new GMlib::PButterfly<double>();
	//_widget->insert( mycurve );
	//mycurve->replot(1000);

	//GMlib::PCurveDerivativesVisualizer<double> *myViz = new GMlib::PCurveDerivativesVisualizer<double>();
	//myViz->setSize(0.1);
	//myViz->setDerivative(1);
	//myViz->setMode(GMlib::GM_PCURVE_DERIVATIVESVISUALIZER_SIZE::GM_PCURVE_DERIVATIVESVISUALIZER_ABSOLUTE);

	//mycurve->insertVisualizer( myViz );

	//mycurve->replot(10000,2);
	
	//GMlib::PFolium<double> *mycurve = new GMlib::PFolium<double>();
	//_widget->insert( mycurve );
	//

	//GMlib::PCurveDerivativesVisualizer<double> *myViz = new GMlib::PCurveDerivativesVisualizer<double>();
	//myViz->setMode(GMlib::GM_PCURVE_DERIVATIVESVISUALIZER_SIZE::GM_PCURVE_DERIVATIVESVISUALIZER_ABSOLUTE);
	//mycurve->insertVisualizer( myViz );
	//mycurve->replot(500,0);

	// Demonstrer BEZIER
	//double siz = 3;

	//DVector< Vector<double,3> > punkter(0);
	//punkter.append( Vector3D<double>(0,0.0,0.0) );
	//punkter.append( Vector3D<double>(0,siz,0.0) );
	//punkter.append( Vector3D<double>(siz,siz,0.0) );
	//punkter.append( Vector3D<double>(siz,0.0,0.0) );
	//punkter.append( Vector3D<double>(2*siz,0.0,0.0) );
	//punkter.append( Vector3D<double>(2*siz,siz,0.0) );


	//GMlib::PTorBezier<double> *tBez = new GMlib::PTorBezier<double>( punkter );
	//_widget->insert( tBez );
	//tBez->replot(20);
	//tBez->translate( Vector3D<float>(5,0,0) );
	//tBez->showSelectors(false, GMlib::GMcolor::Azure, GMlib::GMcolor::Red );

	//GMlib::PCurveDerivativesVisualizer<double> *myViz = new GMlib::PCurveDerivativesVisualizer<double>();
	//myViz->setMode(GMlib::GM_PCURVE_DERIVATIVESVISUALIZER_SIZE::GM_PCURVE_DERIVATIVESVISUALIZER_ABSOLUTE);
	//tBez->insertVisualizer( myViz );
	//tBez->replot(20,0);
	// Slutt Bez

	//GMlib::PRoseCurve<float>* rose = new GMlib::PRoseCurve<float>();

	///*GMlib::PCurve<float> *myPhattyCurve = new GMlib::PCircle<float>(1.0f);*/
	//GMlib::ERBS<float>* erbsCurve = new GMlib::ERBS<float>(mycurve, 100, 2);
	//_widget->insert( erbsCurve );
	//erbsCurve->replot(1000); 
	//erbsCurve->setColor( GMlib::GMcolor::LawnGreen );
	//erbsCurve->translate( GMlib::Vector3D<float>(-5,0,0) );


	//TorBez *torBezObj = new TorBez( punkter );
	//_widget->insert( torBezObj );
	


//GMlib::PBezierCurve<double> *gmbez = new GMlib::PBezierCurve<double>(punkter);
//_widget->insert(gmbez);
//gmbez->showSelectors(false);
//gmbez->replot(20);
//
//GMlib::PCurveDerivativesVisualizer<double> *myViz2 = new GMlib::PCurveDerivativesVisualizer<double>();
//myViz2->setMode(GMlib::GM_PCURVE_DERIVATIVESVISUALIZER_SIZE::GM_PCURVE_DERIVATIVESVISUALIZER_ABSOLUTE);
//gmbez->insertVisualizer( myViz2 );
//gmbez->replot(20,0);

// B - spline
//GMlib::PBSplineCurve<double> *curve = new GMlib::PBSplineCurve<double>(punkter, 1);
//curve->setControlPoints( punkter );
//_widget->insert(curve);
//curve->replot(10);
//
//GMlib::PCurveDerivativesVisualizer<double> *myViz2 = new GMlib::PCurveDerivativesVisualizer<double>();
//myViz2->setMode(GMlib::GM_PCURVE_DERIVATIVESVISUALIZER_SIZE::GM_PCURVE_DERIVATIVESVISUALIZER_ABSOLUTE);
//curve->insertVisualizer( myViz2 );
//curve->replot(20,0);

	
//DMatrix< Vector<float, 3> > c(3,3);
//c[0][0] = Vector3D<float>(  0.0f,  0.0f,  0.0f );
//c[0][1] = Vector3D<float>(  0.0f,  5.0f,  0.0f );
//c[0][2] = Vector3D<float>(  0.0f, 10.0f,  0.0f );
//
//c[1][0] = Vector3D<float>(  5.0f,  0.0f,  0.0f );
//c[1][1] = Vector3D<float>(  5.0f,  5.0f, 10.0f );
//c[1][2] = Vector3D<float>(  5.0f, 10.0f,  0.0f );
//
//c[2][0] = Vector3D<float>( 10.0f,  0.0f,  0.0f );
//c[2][1] = Vector3D<float>( 10.0f,  5.0f,  0.0f );
//c[2][2] = Vector3D<float>( 10.0f, 10.0f,  0.0f );
//
//// Create Surface
//GMlib::PBezierSurf<float> *bzsurf = new GMlib::PBezierSurf<float>( c );
//
//// Replot
//bzsurf->replot( 20, 20 );
//
//// Insert in scene
//_widget->insert( bzsurf );

}

























